﻿
using Autodesk.AutoCAD.ApplicationServices;
using TestCommandProject.CommandManager;
using XYCAM.CadEngine.Command.Attributes;


namespace TestCommandProject;



/// <summary>
/// 自定义的命令数据类,(必须要继承自XyCommandDto),不然会找不到命名空间
/// </summary>
/// <param name="command"></param>
public class MyCommandDto(string command) : XyCommandDto(command)
{
    /// <summary>
    /// 你可以扩展自己的数据
    /// </summary>
    public string Hint { get; set; } = string.Empty;

}


/// <summary>
/// 自定义的命令对象,必须要继承自XyCommandObject才能被生成器识别
/// </summary>

[XyCommandObject]//这个特性可以不用,如果用了的话.生成器会生成一个CommandManager的静态类,将所有命令对象加入到其中的集合中,在有多组命令时可以用上
public partial class MyCommandObject : XyCommandObject<MyCommandDto>
{
    /// <summary>
    /// 被标记了XyCommand的方法会自动生成一个命令数据对象,这个数据对象在这里是MyCommandDto
    /// </summary>
    [XyCommand]
    void Test01() => Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("测试命令1");

    [XyCommand]
    void Test02() => Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("测试命令2");

    [XyCommand]
    void Test03() => Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("测试命令2");
}



/// <summary>
/// 自定义的命令对象2,多个命令对象都会被加入CommandManager的CommandObjects集合中
/// </summary>
[XyCommandObject]
public partial class MyCommandObject002 : XyCommandObject<MyCommandDto>
{
    [XyCommand]
    void Test01() => Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("测试命令1");

    [XyCommand]
    void Test02() => Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("测试命令2");

    [XyCommand]
    void Test03() => Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("测试命令2");
}



public class 测试
{
    /// <summary>
    /// 入口,你也可以在其它地方写
    /// </summary>
    [CommandMethod("TTTT")]
    public void TTTT()
    {
        //获取命令管理器,这个静态类是由生成器生成的
        var manager = TestCommandProject_CommandManager.CommandObjects;
        MyCommandObject? obj1 = new MyCommandObject();
        //修改测试命令1的快捷键
        obj1.Test01Command.QuickCommand = "TTT999";

        //然后输入TTT999就可以执行命令了

    }

}